Skip to content

Commit b53f440

Browse files
committed
squash
1 parent e98c3f2 commit b53f440

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

examples.tel

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,22 @@ MyInt = let wrapper = \h -> ( \i -> if not i
2121
)
2222
in wrapper (# wrapper)
2323

24-
aux = \x -> if dEqual x 0 then "Success" else "Failure"
25-
main = \i -> (aux ((left MyInt) 0), 0)
24+
aux = \x -> if dEqual x 8 then "Success" else "Failure"
25+
main = \i -> (aux ((left MyInt) 8), 0)
26+
27+
[Nat, toNat, nPlus, nMinus]
28+
= let wrapper = \h ->
29+
let N = \(hc, _) x -> assert (dEqual hc h) "not Natural"
30+
in [ N
31+
, \x -> (h, x)
32+
, \((_, aa) : N) ((_, bb) : N) -> (h, d2c aa succ bb)
33+
, \((_, aa) : N) ((_, bb) : N) ->
34+
let sLeft = \x -> case x of
35+
(l, _) -> l
36+
y -> abort "can't subtract larger number from smaller one"
37+
in (h, d2c bb sLeft aa)
38+
]
39+
in wrapper (# wrapper)
2640

2741
-- something
2842
-- main =

src/Telomare/Parser.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{-# LANGUAGE LambdaCase #-}
22
{-# LANGUAGE ScopedTypeVariables #-}
3+
{-# LANGUAGE TupleSections #-}
34
{-# LANGUAGE TypeFamilies #-}
45

56
module Telomare.Parser where
67

78
import Control.Comonad.Cofree (Cofree (..), unwrap)
89
import Control.Lens.Plated (Plated (..))
9-
import Control.Monad (void, join)
10+
import Control.Monad (join, void)
1011
import Control.Monad.State (State)
1112
import Data.Bifunctor (Bifunctor (first, second), bimap)
1213
import Data.Functor (($>))
@@ -354,7 +355,7 @@ parseImportQualified = do
354355
parseOneAssignmentOrBrand :: TelomareParser (String, AnnotatedUPT)
355356
parseOneAssignmentOrBrand =
356357
parseAssignment
357-
<|> ((\exp -> ("8@$temp_label$@8", exp)) <$> parseBrand)
358+
<|> (("8@$temp_label$@8",) <$> parseBrand)
358359

359360
-- |Parse assignment or Brands, and add adding binding to ParserState.
360361
parseAssignmentsAndBrands :: TelomareParser [(String, AnnotatedUPT)]
@@ -363,7 +364,7 @@ parseAssignmentsAndBrands = do
363364
let removeBrands = \case
364365
("8@$temp_label$@8", exp) -> expandBrand exp
365366
x -> [x]
366-
pure . join $ removeBrands <$> tempBindingList
367+
pure (removeBrands =<< tempBindingList)
367368

368369
-- |Parse top level expressions.
369370
parseTopLevelWithExtraModuleBindings :: [(String, AnnotatedUPT)]

0 commit comments

Comments
 (0)