Skip to content

Commit

Permalink
Attempt to add support for Rational & friends.
Browse files Browse the repository at this point in the history
This fails because takeWhile can't be singletonized,
which in turn is because of #113 and friends. Oh well.
  • Loading branch information
Richard Eisenberg committed Sep 16, 2015
1 parent 2ed777d commit 936c33c
Show file tree
Hide file tree
Showing 6 changed files with 509 additions and 25 deletions.
9 changes: 8 additions & 1 deletion src/Data/Singletons/Names.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Data.Typeable ( TypeRep )
import Data.Singletons.Util
import Data.Proxy ( Proxy(..) )
import Control.Monad
import GHC.Real

anyTypeName, boolName, andName, tyEqName, compareName, minBoundName,
maxBoundName, repName,
Expand All @@ -38,7 +39,7 @@ anyTypeName, boolName, andName, tyEqName, compareName, minBoundName,
kindOfName, tyFromIntegerName, tyNegateName, sFromIntegerName,
sNegateName, errorName, foldlName, cmpEQName, cmpLTName, cmpGTName,
singletonsToEnumName, singletonsFromEnumName, enumName, singletonsEnumName,
equalsName :: Name
equalsName, ratioConName, tyFromRationalName, sFromRationalName :: Name
anyTypeName = ''Any
boolName = ''Bool
andName = '(&&)
Expand Down Expand Up @@ -105,6 +106,9 @@ singletonsFromEnumName = mk_name_v "Data.Singletons.Prelude.Enum" "fromEnum"
enumName = ''Enum
singletonsEnumName = mk_name_tc "Data.Singletons.Prelude.Enum" "Enum"
equalsName = '(==)
ratioConName = '(:%)
tyFromRationalName = mk_name_tc "Data.Singletons.Prelude.Real" "FromRational"
sFromRationalName = mk_name_v "Data.Singletons.Prelude.Real" "sFromRational"

singPkg :: String
singPkg = $( (LitE . StringL . loc_package) `liftM` location )
Expand Down Expand Up @@ -157,6 +161,9 @@ promoteTySym name sat
| name == nilName
= mkName $ "NilSym" ++ (show sat)

| name == ratioConName -- this clashes with the exported % operator. Urgh.
= promoteTySym (mkName "::%") sat

-- treat unboxed tuples like tuples
| Just degree <- tupleNameDegree_maybe name `mplus`
unboxedTupleNameDegree_maybe name
Expand Down
Loading

0 comments on commit 936c33c

Please sign in to comment.