Skip to content

Instantly share code, notes, and snippets.

@MarcelineVQ
Created April 21, 2020 22:13
Show Gist options
  • Select an option

  • Save MarcelineVQ/ba31bb157acbd836140b2000c681a596 to your computer and use it in GitHub Desktop.

Select an option

Save MarcelineVQ/ba31bb157acbd836140b2000c681a596 to your computer and use it in GitHub Desktop.
module Main
Semigroup b => Semigroup (a -> b) where
f <+> g = \x => f x <+> g x
Monoid b => Monoid (a -> b) where
neutral = const neutral
[all] Semigroup Bool where
x <+> y = x && y
public export
alphaNum : Char -> Bool
alphaNum = isDigit <+> isAlpha
-- this uses the a -> b instance, how can I tell it to then use [all] for b?
{-
Error(s) building file Test.idr: Test.idr:14:1--18:1:When elaborating right hand side of Main.alphaNum:
Test.idr:14:12--18:1:Can't solve goal ($resolved998 (({arg:5532} : Char) -> $resolved1048))
at line 14, character 12, file Test.idr
While processing right hand side of alphaNum at Test.idr:14:1--18:1:
Can't find an implementation for Semigroup (Char -> Bool)
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment