Search This Blog

Tuesday, May 13, 2014

Unicode in Haskell Source

After writing Unicoded Python, I discovered that Haskell can do some of this already.  No its not even half way there but I am still mighty pleased!

import qualified Data.Set as Set
-- The commented lines are for things that still dont work as one may like

-- Experimenting with Unicode in Haskell source

-- Numbers

x ≠ y   = x /= y
x ≤ y   = x <= y
x ≥ y   = x >= y
x ÷ y   = divMod x y
x ⇑ y   = x ^ y

x × y   = x * y -- readability hmmm !!!

π = pi 


-- ⌊ x = floor x
-- ⌈ x = ceiling x

-- Lists       
xs ⤚ ys = xs ++ ys

-- Bools

x ∧ y   = x && y
x ∨ y   = y || y

-- ¬x = not x

-- Sets

x ∈ s   = x `Set.member` s -- or keep ∈ for list elem?
s ∪ t   = s `Set.union` t
s ∩ t   = s `Set.intersection` t
s ⊆ t   = s `Set.isSubsetOf` t
s ⊂ t   = s `Set.isProperSubsetOf` t
s ⊈ t   = not (s `Set.isSubsetOf` t)

-- ∅ = Set.null

No comments:

Post a Comment